﻿using System;
using System.Collections.Generic;
using System.Text;

namespace OrderExer
{
    //订单明细
    internal class OrderDetails
    {
        Customer customer;//客户对象
        Commodity commodity;//商品对象
        
        public OrderDetails(string cusname,string age,string comname,string date)
        {
            customer = new Customer(cusname, age);
            commodity = new Commodity(comname, date);
        }

        public override bool Equals(object obj)
        {
            return obj is OrderDetails details &&
                   EqualityComparer<Customer>.Default.Equals(customer, details.customer) &&
                   EqualityComparer<Commodity>.Default.Equals(commodity, details.commodity);
        }

        public override int GetHashCode()
        {
            return HashCode.Combine(customer, commodity);
        }

        public override string ToString()
        {
            return " 客户信息：" + this.customer.ToString() + ",商品信息：" + this.commodity.ToString();
        }
    }
}
